# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=gitoxide
pkgver=0.14.0
pkgrel=1
pkgdesc="An idiomatic, lean, fast & safe pure Rust implementation of Git"
url="https://github.com/Byron/gitoxide"
# armhf, armv7, ppc64le, s390x: fails to build crate sha1-asm
# riscv64: zlib-ng-dev is not available yet
arch="all !armhf !armv7 !ppc64le !riscv64 !s390x"
license="Apache-2.0 OR MIT"
makedepends="
	cargo
	cargo-auditable
	curl-dev
	zlib-dev
	zlib-ng-dev
	"
checkdepends="
	bash
	git-daemon
	xz-dev
	"
source="https://github.com/Byron/gitoxide/archive/v$pkgver/gitoxide-$pkgver.tar.gz
	system-curl.patch
	zlib-ng.patch
	skip-online-tests.patch
	"

options="!check" # tests need update to new version

# unwind is required to assure that destructors are called, important for
# tempfiles (comment from Cargo.toml).
export CARGO_PROFILE_RELEASE_PANIC="unwind"

_cargo_opts="--frozen --no-default-features --features lean"


prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libz-ng.
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		z-ng = { rustc-link-lib = ["z-ng"], rustc-cfg = ["zng"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build $_cargo_opts --release
}

check() {
	# CI - skip tests that require TTY.
	CI=1 make journey-tests
}

package() {
	install -D -m755 target/release/gix -t "$pkgdir"/usr/bin/
	install -D -m755 target/release/ein -t "$pkgdir"/usr/bin/
}

sha512sums="
2bd4c20a71ef3f37e37ef54d271fa5df9f43b7b396923e581ce1ae5f9b87969eabdc300267f365aeb5c06f83f2ccc68e2f709bee006ee54a6e65774f93979642  gitoxide-0.14.0.tar.gz
e512f0b9904b57b181a5d203ffbed85bd2aed6db44b255bc7e370ec6ef94d0d6dbe8f62b334e8d7b980728cc10f7a3fd694487a73031e8a953604d2e2f1d9192  system-curl.patch
ad2b931dfcecbf099d3b6c1abc4e9522016f60486b20f23a73bac55fe3061aa97236e877c53a1b1709495885e5f820a721c9d1a86dd99d72e09e21758135b50e  zlib-ng.patch
eabb202211c28ed6209522f39b6ae32e0f51c9ed71943c41a18550f236064f676b1b88d6ff0baa5490c7e76bea43ba06f04653824a6af50355d4eb6cfc92cf9e  skip-online-tests.patch
"
